package com.novel.entiy.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.novel.entiy.Novel;
import com.novel.utils.BeanConverter;
import com.novel.utils.ConverterUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author tanghao
 * @date 2022/4/7
 */
@Data
public class NovelDTO implements BeanConverter<Novel>, Serializable {

    @ApiModelProperty(value = "")
    private Long id;

    /**
     * 标题
     */
    @Size(min = 3,max = 30,message = "标题字数应在3-30之间")
    @NotBlank(message = "标题不能为空")
    @ApiModelProperty(value = "标题")
    private String title;

    /**
     * 简介
     */
    @Size(min = 50,max = 1000,message = "简介字数应在50-1000之间")
    @NotBlank(message = "简介不能为空")
    @ApiModelProperty(value = "简介")
    private String introduction;

    /**
     * 作者名称
     */
    @ApiModelProperty(value = "作者名称")
    private String authorName;

    /**
     * 作者id
     */
    @ApiModelProperty(value = "作者id")
    private Long authorId;

    /**
     * 阅读数
     */
    @ApiModelProperty(value = "阅读数")
    private Long browseNums;

    /**
     * 字数
     */
    @ApiModelProperty(value = "字数")
    private Long wordNums;

    /**
     * 订阅数
     */
    @ApiModelProperty(value = "订阅数")
    private Long subscribeNums;

    /**
     * 热度
     */
    @ApiModelProperty(value = "热度")
    private Long hotNums;

    /**
     * 0:连载中 1:已完结
     */
    @ApiModelProperty(value = "0:连载中 1:已完结 2:审核中 3:审核失败")
    private Integer status;

    /**
     * 是否收费
     */
    @ApiModelProperty(value = "是否收费")
    private Integer isCharge;

    /**
     * 每章收费金额
     */
    @ApiModelProperty(value = "每章收费金额")
    private Long chargeAmount;

    /**
     * 打赏金额总数
     */
    @ApiModelProperty(value = "打赏金额总数")
    private Long rewardAmount;

    /**
     * 评论数
     */
    @ApiModelProperty(value = "评论数")
    private Long commentNums;

    /**
     * 封面
     */
    @ApiModelProperty(value = "封面")
    private String cover;

    /**
     * 评分
     */
    @ApiModelProperty(value = "评分")
    private BigDecimal score;

    /**
     * 分类id
     */
    @NotNull(message = "必须选择一个分类")
    @ApiModelProperty(value = "分类id")
    private Integer classifyId;



    /**
     * 转换接口方法
     *
     * @return T
     */
    @Override
    public Novel doForward() {
        Novel novel = new Novel();
        ConverterUtil.copyPropertiesIgnoreNull(this,novel);
        return novel;
    }
}
